<?php
Junction_FileCabinet::using("Junction_Utils_IO_Exception");

/**
 * Class which encapsulates common directory operations
 *
 * @package junction.utils.io
 * @author Alexander Schearer <aas11@duke.edu>
 */
class Junction_Utils_IO_Directory implements IteratorAggregate {
	
	/**
	 * @var dir_handle
	 */
	private $_directory;
	
	/**
	 * @var string
	 */
	private $_path;
	
	/**
	 * Construct a new directory object
	 *
	 * @throws Utils_IO_Exception
	 * 
	 * @param string $path
	 */
	public function __construct($path) {
		if (!is_dir($path)) {
			throw new Junction_Utils_IO_Exception("Passed value is not a directory: " . $path);
		}
		$this->_path = $path;
	}
	
	public function getIterator() {
		return new DirectoryIterator($this->_path);
	}
	
	
}
?>